/* 1 if filter application was successful and the output (>1B) is in outname, 2 if some pattern matched but there is no output, 0 otherwise: sep 15-18 '94 */
/* memagrep is initialized in partition.c for calls from dir.c, and it is already done by the time we call this function from main.c */
apply_filter(inname, outname)
char *inname, *outname; /* outname is in-out, inname is in */
{
int i;
char name[MAX_LINE_LEN];
int name_len = strlen(inname);
char s[MAX_LINE_LEN];
FILE *dummyout;
FILE *dummyin;
char dummybuf[4];
char prevoutname[MAX_LINE_LEN];
char newoutname[MAX_LINE_LEN];
int ret = 0;
int unlink_prevoutname = 0;
if (num_filter <= 0) return 0;
if ((dummyout = fopen("/dev/null", "w")) == NULL) return 0;
/* ready for memgrep */
name[0] = '\n';
strcpy(name+1, inname);
strcpy(prevoutname, inname);
strcpy(newoutname, outname);
/* Current properly filtered output is always in prevoutname */
for(i=0; i<num_filter; i++) {
if (filter_len[i] > 0) {
char *suffix;
name[name_len + 1] = '\0';
/* if (strstr(name+1, filter[i]) != NULL) { Chris Dalton */
if ((suffix = strstr(name+1, filter[i])) != NULL) {
if (ret == 0) ret = 2;
/* yes, it matched: now apply the command and get the output */